<!DOCTYPE html>
<!--[if IE 9]>         <html class="ie9 no-focus" lang="zh"> <![endif]-->
<!--[if gt IE 9]><!-->
<html class="no-focus" lang="zh" xmlns="http://www.w3.org/1999/html"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <title>食堂预约扫码系统</title>
    <meta name="description" content="">
    <meta name="author" content="caiweiming">
    <meta name="robots" content="noindex, nofollow">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0">
    <link rel="shortcut icon" href="__ADMIN_IMG__/favicons/favicon.ico">
    <link rel="stylesheet" href="__ADMIN_CSS__/bootstrap.min.css">
    <link rel="stylesheet" id="css-main" href="__ADMIN_CSS__/oneui.css">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_626784_mcjb2yy4vfl.css" />

</head>
<body>

<div class="content">

    <div class="row " style="background-color: white">
        <label class="col-xs-12" >预定用餐时间</label>
        <div class="form-group col-lg-8 col-md-5 col-sm-8 col-xs-8 " >
           <!-- <label class="col-xs-12" >预定用餐时间</label>-->
            <div class="col-xs-12">
                <input class="js-datepicker form-control"  type="date" id="date" name="date" value="" >
            </div>
            <div class="col-xs-12" style="margin-top: 2px">
                <input type="checkbox" name="attr_name" id="attr_name" value="早餐"><span>早餐</span>
                <input type="checkbox" name="attr_name" id="attr_name" value="午餐"><span>午餐</span>
                <input type="checkbox" name="attr_name" id="attr_name" value="晚餐"><span>晚餐</span>
            </div>
        </div>

        <div class="form-group col-lg-3 col-md-6 col-sm-3 col-xs-3" >
            <div class="col-xs-12">
                <button class="btn btn-success" id="add">加入</button>
            </div>
        </div>
    </div>


    <div class="blank">
        <div class="builder-table-body" id="builder-table-body" style="max-height: 123px;">
            <table class="table table-builder table-hover table-bordered table-striped js-table-checkable-target" id="builder-table-main">

                <tbody>
                <tr class="">

                    <td class=" ">
                        <div class="table-cell">王某某</div>
                    </td>
                    <td class=" ">
                        <div class="table-cell">CCB255685676275d </div>
                    </td>

                    <td class=" ">
                        <div class="table-cell">充值</div>
                    </td>

                </tr>

                </tbody>

            </table>
        </div>
    </div>


</div>



<script src="__ADMIN_JS__/core/jquery.min.js"></script>
<script src="__LIBS__/jquery-validation/jquery.validate.min.js"></script>
<script src="__ADMIN_JS__/core/bootstrap.min.js"></script>

<script>
    var tableLite=[]
    $('#add').click(function (){
        var arr =[];
        var sub_data=[];
        date = $("input[name='date']").val();

        if ($.trim(date)=='') return false;

        $("input[type=checkbox]").each(function(){
            if(this.checked){
                //alert($(this).val());
                sub_data.push({
                    "attr_name": $(this).val(),
                    "start_time": ''
                })
            }
        });


        arr.push({
            "date":date,
            "comid":'',
            "sub_data":sub_data
        })

        // if($.inArray(arr,tableLite) < 0){ // 判断arr数组中的元素是否存在于a数组种
        //     tableLite.push(arr); // 不存在则将该元素存放于a数组中
        // }
        console.log(arr)
        for (i=0;i<=tableLite.length;i++){

            if(tableLite[i].date==date){ // 判断arr数组中的元素是否存在于a数组种
                tableLite.push(tableLite[i]); // 不存在则将该元素存放于a数组中
            }


        }

         console.log(tableLite)
    })

</script>


</body>
</html>